import request from '@/utils/request'

/**
 * 获取员工简单列表
 * @returns promise
 */
export const getEmployeesList = () => {
  return request({
    url: '/sys/user/simple',
    method: 'GET'
  })
}

/**
 * 获取员工列表
 * @param {*} params
 * @returns promise
 */
export const getEmployeesLists = (params) => {
  return request({
    url: '/sys/user',
    method: 'GET',
    params
  })
}

/**
 * 新增员工
 * @param {*} data
 * @returns promise
 */
export const addEmployees = (data) => {
  return request({
    url: '/sys/user',
    method: 'POST',
    data
  })
}

/**
 * 删除员工
 * @param {*} id
 * @returns promise
 */
export const delEmployees = (id) => {
  return request({
    url: `/sys/user/${id}`,
    method: 'delete'
  })
}

/**
 * 批量导入员工
 * @param {*} data
 * @returns promise
 */
export const importEmployees = (data) => {
  return request({
    url: '/sys/user/batch',
    method: 'POST',
    data
  })
}

/**
 * 获取员工基本信息
 * @param {*} id
 * @returns promise
 */
export const getEmployeesInfo = (id) => {
  return request({
    url: '/sys/user/' + id,
    method: 'GET'
  })
}

/**
 * 保存员工信息
 * @param {*} data
 * @returns promise
 */
export const updateEmployeesInfo = (data) => {
  return request({
    url: '/sys/user/' + data.id,
    method: 'PUT',
    data
  })
}

/**
 * 获取员工个人详情
 * @param {*} id 员工id
 * @returns promise
 */
export const getEmployeesDetail = (id) => {
  return request({
    url: '/employees/' + id + '/personalInfo',
    method: 'GET'
  })
}

/**
 * 更新员工详细信息
 * @param {*} data {}
 * @returns promise
 */
export const updateEmployeesDetail = (data) => {
  return request({
    url: '/employees/' + data.id + '/personalInfo',
    method: 'PUT',
    data
  })
}

/**
 * 获取员工岗位信息
 * @param {*} id 用户id
 * @returns promise
 */
export const getEmployeesJobInfo = (id) => {
  return request({
    url: '/employees/' + id + '/jobs',
    method: 'GET'
  })
}

/**
 * 保存员工岗位信息
 * @param {*} data {}
 * @returns promise
 */
export const updateEmployeesJobInfo = (data) => {
  return request({
    url: '/employees/' + data.id + '/jobs',
    method: 'PUT',
    data
  })
}

/**
 * 分配员工角色
 * @param {*} data 对象：id：员工id，roleids: 角色id集合
 * @returns promise
 */
export const updateEmployeesRoles = (data) => {
  return request({
    url: '/sys/user/assignRoles',
    method: 'PUT',
    data
  })
}
